package com.ag.zhh.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ag.bean.TbEvent;
import com.ag.bean.TbEventPlan;
import com.ag.bean.TbPlan;
import com.ag.dao.TbEventPlanDAO;

public class ZHHEventPlanDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(TbEventPlanDAO.class);

	public TbPlan findPlanByEId(String eId) {
		TbPlan plan = null;
		String hql = "from TbEventPlan  eq join fetch eq.tbPlan where eq.EId = "
				+ eId;
		try {
			System.out.println(getHibernateTemplate().find(hql).size()+"----------------------------getHibernateTemplate().find(hql).size()----------------------------");
			if (getHibernateTemplate().find(hql).size() > 0) {
				TbEventPlan instance = (TbEventPlan) getHibernateTemplate()
						.find(hql).get(0);
				plan = instance.getTbPlan();
				return plan;
			}
			return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
}
